﻿//  Copyright (c) 2011 Ray Liang (http://www.dotnetage.com)
//  Licensed MIT: http://www.opensource.org/licenses/mit-license.php

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DNA.Mvc.Publishing
{
    public interface IArticleRepository:IRepository<Article>
    {
        IQueryable<Article> GetChildren(int parentID);

        bool HasChildren(int id);

        Article Read(int id, string username, string ip, string userAgent);

        /// <summary>
        /// Gets the article count by specified category id.
        /// </summary>
        /// <param name="categoyID">The category id.</param>
        /// <returns>The integer value.</returns>
        int CountForCategory(int categoryID);

        /// <summary>
        /// Gets the articles in specified id value array.
        /// </summary>
        /// <param name="articlesIDs">The article id value array.</param>
        /// <returns>A article collection</returns>
        IQueryable<Article> Includes(int[] articlesIDs);

        /// <summary>
        /// Movet the article to new position or attach to another parent category.
        /// </summary>
        /// <param name="articleID">Specified the article id which to move.</param>
        /// <param name="pos">Specified the new position to move to.</param>
        /// <param name="categoryID">Specified the parent category id of the article.</param>
        void Move(int articleID, int pos, int categoryID);

        /// <summary>
        /// Vote the specified article.
        /// </summary>
        /// <param name="articleID">Specified the article id to vote.</param>
        /// <param name="value">Specified the rating value.</param>
        ///// <param name="totalRatings"></param>
        /// <returns></returns>
        Article Vote(int articleID, int value, string ip, string userName);
        
        /// <summary>
        /// Get the article by specified permalink url.
        /// </summary>
        /// <param name="url">The permalink url.</param>
        /// <returns>An article instance or null</returns>
        Article Find(Uri uri);

        ///// <summary>
        ///// Gets the total read value by specfied article id.
        ///// </summary>
        ///// <param name="articleID">The article id. </param>
        ///// <returns>The integer read value.</returns>
        //int GetTotalReads(int articleID);

        int GetPosition(int categoryID);

        IQueryable<Article> GetRecentPosts(int maxResults);
    }
}
